<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面电子时钟</title>
<script src="js/jquery-3.2.1.min.js"></script>
<style>
    p {
      font-size: 50px;
      font-weight: 25px;
    }
  </style>
</head>
<body>
    <p id="clock">在这里显示电子时钟</p>
    <script>
            function showTime(){
                var now=new Date();
                var year =now.getFullYear();
                var month=now.getMonth()+1;
                var date =now.getDate();
                var hour=now.getHours();
                var minute=now.getMinutes();
                var seconds=now.getSeconds();
                if (month >= 1 && month <= 9) {
                    month = "0" + month;
                }
                if (date >= 0 && date <= 9) {
                    date = "0" + date;
                }
                if (minute >= 0 && minute <= 9) {
                    minute = "0" + minute;
                }
                if (hour >= 0 && hour <= 9) {
                    hour = "0" + hour;
                }
                if (seconds >= 0 && seconds <= 9) {
                    seconds = "0" + seconds;
                }
                var time_text = year + '年' + month + '月' + date + '日' + hour + ':' + minute + ':' + seconds;
                $("#clock").html(time_text);
                 setTimeout("showTime();", 1000);
                
            }
            showTime();
    </script>
</body>
</html>